package com.linsen.core.common.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

@Getter
@AllArgsConstructor
public enum LoginEndpointType {
    SYSTEM("system","后台PC"),
    APP("app","移动端APP");

    @JsonValue
    private String value;
    private String description;

    private static final Map<String, LoginEndpointType> VALUES = new HashMap<>();

    static {
        for (final LoginEndpointType loginEndpointType : LoginEndpointType.values()) {
            LoginEndpointType.VALUES.put(loginEndpointType.getValue(), loginEndpointType);
        }
    }

    @JsonCreator
    public static LoginEndpointType getByValue(String value) {
        return LoginEndpointType.VALUES.get(value);
    }

    public static LoginEndpointType getByModuleService(ModuleService moduleService){
        LoginEndpointType loginEndpointType = null;
        switch (moduleService){
            case SYSTEM_ADMIN:
            case SYSTEM_BASIC:
            case SYSTEM_CONFIG:
            case SYSTEM_INVENTORY:
                loginEndpointType = LoginEndpointType.SYSTEM;
                break;
            default:
        }
        return loginEndpointType;
    }
}
